filename = 'write.txt'
# w 直接覆盖
# a 在文件末尾附加，不覆盖
with open(filename, 'w') as obj:
    obj.write('test\n')
    obj.write('demo\n')